import java.util.concurrent.Callable;

/**
 * @author zhangdi
 * @version 1.0
 * @date 2021.11.5 10:33
 */
public class ThreadDemo {
    Thread t;

    public void shutdown(){
        System.out.println("[Shutdown]Is Alive " + t.isAlive());
        System.out.println("[Shutdown]Is Interrupted " + t.isInterrupted());
        if(t.isAlive() && t.isInterrupted()){
            t.interrupt();
        }
    }

    public void health(){
        System.out.println("[Health]Is Alive " + t.isAlive());
        System.out.println("[Health]State " + t.getState());
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadDemo threadDemo = new ThreadDemo();
        Thread thread = new Thread(new ThreadAliveTest());
        threadDemo.t = thread;
        threadDemo.health();
        thread.start();
        threadDemo.health();

        Thread.sleep(500);

        threadDemo.shutdown();

        Thread.sleep(500);

        threadDemo.health();

        Thread.sleep(500);

        threadDemo.t.start();
    }
}
